package com.example.leetcode.prcatice;

public class Test239 {

  // 超时了
    public int[] maxSlidingWindow(int[] nums, int k) {
        int len = nums.length;
        if (len == 1){
            return nums;
        }
        int[] result = new int[len-k+1];
        for (int i =0 ;i<len-k+1;i++){
            int r = Integer.MIN_VALUE;
            int index = k;
            while (index>0){
                int t = nums[i+index-1];
                r = Math.max(r,t);
                index --;
            }
            result[i] = r;
        }
        return result;
    }
}



class Demo239{
  public static void main(String[] args) {
      int k = 1;
      int[] nums = {1,-1};
      Test239 t = new Test239();
      int[] ints = t.maxSlidingWindow(nums, k);
      for ( int i: ints) {
        System.out.println(i);
      }

  }
}